package com.maolong.spring.core.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class FileSystemResource implements Resource{
    private final String path;
    private final File file;

    public FileSystemResource(String path) {
        this.path=path;
        this.file=new File(path);
    }

    public FileSystemResource(File file){
        this.file=file;
        this.path=file.getPath();
    }

    public FileSystemResource(String path, File file) {
        this.path=path;
        this.file=file;
    }

    @Override
    public InputStream getInputStream() throws FileNotFoundException {
        return new FileInputStream(file);
    }

    @Override
    public String getFileName() {
        return file.getName();
    }

    public String getPath() {
        return path;
    }
}
